<template>
	<view class="previewImg">
		  <view  @click="goBack" class="topback">
		    <image src="../../static/icon/left.png"></image>
		  </view> 
		<view class="mask">
			<swiper @change="changeSwiper" class="my_swiper" :current="current" :circular="circular" :indicator-dots="indicatorDots" :autoplay="autoplay" :duration="duration">
				<swiper-item v-for="(x, y) in picList" :key="y"> 
						<image style="width: 100%;" :src="x" mode="widthFix"></image>
				 
				</swiper-item>
			</swiper>
		</view>
		<view class="page" v-if="picList.length>0">{{ current + 1 }} / {{ picList.length }}</view>
	</view>
</template>

<script>
var imgUtil = require('../../common/image.js');
export default { 
	data() {
		return {
			picList: [],
			indicatorDots: false,
			autoplay: false,
			duration: 500,
			circular: true,
			current: 0,
			isShowSwiper: false
		};
	},
	onLoad() {
		this.picListInit();
	}, 
	methods: {
		goBack(){
			uni.navigateBack()
		},
		clickPic(index) {
			this.current = index;
			this.isShowSwiper = true;
		},
		async picListInit() {
			this.current = uni.getStorageSync("currentImgIndex");
			this.picList = uni.getStorageSync("imgPreviewPicList");
			this.picList.map(function(item){
				item =imgUtil.getImg(item);
			})
			
		},
		changeSwiper(e) {
			this.current = e.target.current;
		}
	}
};
</script>

<style lang="scss" scoped>
.page {
	position: fixed;
	z-index: 6;
	color: #fff;
	bottom: 20rpx;
	text-align: center;
	width: 100%;
	
}
.topback {
  width: 60rpx;
  height: 60rpx;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  position: absolute;
  top: 44px;
  left: 20px;
  padding:2rpx ;
  z-index: 500;
}

.topback image {
  max-height: 55rpx;
  max-width: 55rpx;
}
.mask {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	align-items: center;
	background-color: #000;
	z-index: 5;
	> .my_swiper {
		width: 100%;
		height: 60vh;
		.bg_img {
			background-size: 100% auto;
			background-repeat: no-repeat;
			background-position:center;
			width: 100%;
			height: 100%;
		}
	}
}

.pic_list {
	display: flex;
	flex-flow: row wrap;
	> view {
		flex: 0 0 33.3vw;
		height: 33.3vw;
		padding: 1vw;
		> image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
